from selenium import webdriver
import time

# 初始化浏览器驱动
driver = webdriver.Chrome()
driver.maximize_window()
# 先访问淘宝首页（必须先访问，否则添加Cookie会报域名错误）
driver.get("https://www.taobao.com")

# 添加手动获取的Cookie（需替换为实际的name和value）
cookies = [
    {"name": "_m_h5_tk", "value": "3367d012ee839340f2059912677c15b4_1761911110487"},
    {"name": "_m_h5_tk_enc", "value": "eeaa8e072ab6abd8f375d39f4dad24b8"},
    {"name": "cookie2", "value": "1ebdcd649b165b97a268ee2c6e2e96a3"},
    {"name": "cna", "value": "TmmLIZ7cgHkCAXQEYMtviruS"},
    {"name": "uc1", "value": "pas=0&cookie21=UtASsssme%2BBq&cookie16=VT5L2FSpNgq6fDudInPRgavC%2BQ%3D%3D&cookie14=UoYY4vIPyBXLwQ%3D%3D&cookie15=V32FPkk%2Fw0dUvg%3D%3D&existShop=false"},
    {"name": "lgc", "value": "%5Cu6F47%5Cu7B710329"},
    {"name": "tracknick", "value": "%5Cu6F47%5Cu7B710329"},
    {"name": "isg", "value": "BMfHJlAEYlqbgebW8rIV7JWJVnuRzJuuDt5Espm099b2COTKoZ8e_UeAruhW4HMm"},
]

for cookie in cookies:
    driver.add_cookie(cookie)

# 刷新页面，使Cookie生效
driver.refresh()
time.sleep(5)  # 等待页面加载



# 关闭浏览器
driver.quit()